package com.ak.routeTopic;

import com.ak.utils.RabbitMQUtils;
import com.rabbitmq.client.*;

import java.io.IOException;

public class Consumer_2 {
    public static void main(String[] args) throws IOException {
        Connection connection= RabbitMQUtils.getConnection();
        // 获取连接中通道
        Channel channel=connection.createChannel();
        String channelName="log_top";
        channel.exchangeDeclare(channelName,"topic");
        // 临时队列
        String queneName=channel.queueDeclare().getQueue();
        // 绑定交换机和队列

        channel.queueBind(queneName,channelName,"admin.*");
        // 消费信息
        channel.basicConsume(queneName,true,new DefaultConsumer(channel){
            @Override
            public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
                System.out.println("消费者admin 的信息 "+new String(body));
            }
        });
    }
}
